/********************************************************************



Write Date: 2011/03/28
Author: Deng Nianchen
>>>> 
	
*********************************************************************/
#ifndef BYTE_STREAM_H
#define BYTE_STREAM_H
#include <string.h>
#include <string>
#include "OOPUtilsGlobal.hpp"
#include "OOPObject.h"



_OOPUTILS_BEGIN



class _EXPORT_UTILS_CLASS ByteStream : public OOPObject
{

private:

  char * _data;
  size_t _length;
  size_t _capacity;
  size_t _wpos;
  size_t _rpos;

  void _expandTo (size_t newSize);

public:

  ByteStream ();
  ByteStream (const char * data, size_t length);
  ByteStream (const ByteStream & right);

  ~ByteStream ();

  const char * getBytes () const;

  size_t getLength () const;

  ByteStream & operator<< (const char & right);
  ByteStream & operator<< (const int & right);
  ByteStream & operator<< (const float & right);
  ByteStream & operator<< (const double & right);
  ByteStream & operator<< (const bool & right);
  ByteStream & operator<< (const char * right);
  ByteStream & operator<< (const std::string & right);

  const ByteStream & operator>> (char & right) const;
  const ByteStream & operator>> (int & right) const;
  const ByteStream & operator>> (float & right) const;
  const ByteStream & operator>> (double & right) const;
  const ByteStream & operator>> (bool & right) const;

};



_OOPUTILS_END



#endif